import os
import unittest

#1. 运行器
from basic.class18_unitest import HTMLTestRunner

testloader= unittest.TestLoader()
# 收集测试用例
dir_name = os.path.dirname(os.path.abspath(__file__))
test_case = os.path.join(dir_name,"test_cases")

testsuit = testloader.discover(test_case)

# 执行
report_path = os.path.join(dir_name,'report')
if not os.path.exists(report_path):
    os.mkdir(report_path)

report_html = os.path.join(report_path,'report.html')
with open(report_html,'wb') as f:
    runner = HTMLTestRunner.HTMLTestRunner(f,verbosity=2,title="dieselTesting")
    runner.run(testsuit)
print(testsuit)